package blue.web.exam.service;

import blue.exam.dao.TikuSourceMapper;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class TikuGetDataService{


    @Autowired
    private RestTemplate restTemplate;


    public void getFromYunxiao(String name){
       String nodeData=restTemplate.getForObject(String.format("http://tiku.yunxiao.com/api/question/selector/?period=%s",name),String.class);
       JSONObject nodeObject=JSONObject.parseObject(nodeData);
       for(int i=0;i<nodeObject.getJSONArray("children").size();i++){
           JSONObject subjectChildrenObject = nodeObject.getJSONArray("children").getJSONObject(i);
           for(int j=0;j<subjectChildrenObject.getJSONArray("children").size();j++){
               JSONObject modeChildrenObject = subjectChildrenObject.getJSONArray("children").getJSONObject(j);
               for(int k=0;k<modeChildrenObject.getJSONArray("children").size();k++){
                   JSONObject pressChildrenObject = modeChildrenObject.getJSONArray("children").getJSONObject(k);
                   for(int m=0;m<pressChildrenObject.getJSONArray("children").size();m++){
                       JSONObject gradeChildrenObject = pressChildrenObject.getJSONArray("children").getJSONObject(m);
                       for(int n=0;n<gradeChildrenObject.getJSONArray("children").size();n++){
                           JSONObject itemObject = gradeChildrenObject.getJSONArray("children").getJSONObject(n);

                       }
                   }
               }
           }
       }

    }



}
